package org.example;

import java.lang.reflect.Method;

//say hello 增强
public class MyHelloHandler implements MyInvocationHandler {

    private final Object target;


    public MyHelloHandler(Object target) {
        this.target = target;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //前后说hello
        System.out.println("before say hello"+proxy.getClass().getName());
        Object result = method.invoke(target, args);
        System.out.println("after say hello");
        return result;
    }

}
